<?php							
		class CCategory extends database
		{
			var $table = 'cdb_category';
			
			public function CCategoryeSearchResult($keyWord)
			{
				$sql="select * from $this->table where name like '{$keyWord}'";
				$this->setQuery($sql);
				$this->query();
				$arr = $this->loadAllRow();
				
				$numOfRow = mysql_affected_rows();
				
				if($numOfRow>0)
					return $arr;
				else
					return -1;				
			}
			
			
			public function CCategoryList()
			{
				$sql="select * from {$this->table}";
				$this->setQuery($sql);
				$this->query();

				
				$arrTemp =  $this->loadAllRow();
				
				
				$numOfRow = mysql_affected_rows();
				if($numOfRow>0)
					return $arrTemp; 
				else
					return -1;
			}
			
			public function CCategoryDetail ($id)
			{
				$sql="select * from $this->table where id='{$id} '";
				$this->setQuery($sql);
				$this->query();
				$arr=$this->loadAllRow();
				
				$numOfRow = mysql_affected_rows();
				if($numOfRow>0)
					return $arr[0];
				else
					return -1;

			}
			
			
			
			public function CCategoryAdd ($name,$description,$status)
			{
				$sql = "INSERT INTO {$this->table} (`name`,`description`,`status`)
	VALUES ('{$name}','{$description}','{$status}');";
				
				$this->setQuery($sql);
				$this->query();
				
				return mysql_affected_rows();									
			}
			
			public function CCategoryUpdate ($id,$name,$description,$status)
			{
				$sql = "update $this->table set name ='{$name}',description ='{$description}',status ='{$status}' where id = '{$id}' ";
			
				$this->setQuery($sql);
				$this->query();
				return mysql_affected_rows();
			}
			
			public function CCategoryDelete($id)
			{
				$sql="Delete from  $this->table where id='{$id}'";
				$this->setQuery($sql);
				$this->query();
				return mysql_affected_rows();
			}			
		}	
	
	
	?>